<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">
				聊天记录
			</block>
		</cu-custom>
		<a-scroll :request="get" ref="aScroll" :parm="{pageSize}">
			<template #item="{row:x,index}">
				<a-list :hide-icon="true" :value="x"></a-list>
			</template>
		</a-scroll>
		<view class="bottom-a-tabs">
			<a-tabs color="#0055ff" :index='1' :height="50" type="border" :value="nav" @click="go">
				<template #book="{row,index}">
					<text class="iconfont icon-tongxunlu" style="font-size: 1.2em;"></text>
					通讯录
				</template>
				<template #msg="{row,index}">
					<text class="iconfont icon-liaotianjilu" style="font-size: 1.2em;"></text>
					聊天记录
				</template>
			</a-tabs>
		</view>
	</view>
</template>

<script>
	export default {
		//上拉触底
		onReachBottom() {
			this.$refs.aScroll.lower();
		},
		//下拉刷新
		onPullDownRefresh() {
			this.$refs.aScroll.get(true).then(res => {
				uni.stopPullDownRefresh();
			});
		},
		data() {
			return {
				nav: [{
					slot: "book",
					disabled: true,
					url: '/pages/parents/AddressBook/AddressBook'
				}, {
					slot: 'msg'
				}],
				pageSize:30
			}
		},
		methods: {
			go({
				url
			}) {
				uni.redirectTo({
					url
				});
			},
			get(parm = {}) {
				const data = new Array(this.pageSize).fill({
					name: "上山打老虎",
					phone: "3分钟前",
					sonTitle: "今晚去不去吃饭？士大夫士大夫十分帝膳房士大夫是",
					num: 2,
					img: "https://weiliicimg6.pstatp.com/weili/l/323181772063899692.webp"
				});
				console.log('请求：' + JSON.stringify({
					...parm
				}))
				return new Promise(r => {
					setTimeout(e => {
						r({
							total: 200,
							data
						})
					}, 1000);
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
	}

	.bottom-a-tabs {
		height: 50px;

		.a-tabs {
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			z-index: 998;
			padding-bottom: 2px;
			font-size: 18px;

			&::after {
				top: 0;
				bottom: auto;
			}
		}
	}
</style>
